<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="90px"
    >
      <el-form-item label="关键字" prop="searchValue">
        <el-input
          v-model="queryParams.searchValue"
          placeholder="请输入关键字"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="tableList">
      <el-table-column
        label="物联网卡号"
        align="center"
        prop="cardNo"
      />
      <el-table-column
        label="使用状态"
        align="center"
      >
        <template slot-scope="scope">
          <el-tag type="info">未使用</el-tag>

        </template>
      </el-table-column>
      <el-table-column
        label="初次使用时间"
        align="center"
      >
      </el-table-column>
      <el-table-column
        label="当前绑定设备"
        align="center"
      >
      </el-table-column>
      <el-table-column
        label="流量总统计"
        align="center"
      >
      </el-table-column>
      <el-table-column
        label="备注"
        align="center"
      >
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
      >
      </el-table-column>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { getIotCardList } from "@/api/equipment/equipment.js";
export default {
  name: "InternetOfThings",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        searchValue: undefined,
      },
      tableList: [],
    };
  },
  created() {
    this.getList();
  },
  activated() {
    this.getList();
  },
  methods: {
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.searchValue = null;
      this.handleQuery();
    },
    getList() {
      this.loading = true;
      getIotCardList(this.queryParams).then((response) => {
        this.tableList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
  },
};
</script>

<style lang="scss" scoped></style>
